package com.hhf.feiojcodesandbox.controller;

import com.hhf.feiojcodesandbox.model.ExecuteCodeRequest;
import com.hhf.feiojcodesandbox.model.ExecuteCodeResponse;
import com.hhf.feiojcodesandbox.service.CodeSandbox;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author hhf
 * @Date 2024/10/29
 * @Description
 */
@RestController
@RequestMapping("/")
public class HelloController {

    @Resource
    private CodeSandbox codeSandbox;

    @GetMapping("/health")
    public String healthCheck() {
        return "ok";
    }


    @PostMapping("/execute/code")
    public ExecuteCodeResponse executeCode(@RequestBody ExecuteCodeRequest executeCodeRequest) {
        return codeSandbox.executeCode(executeCodeRequest);
    }


}
